package net.hserver.admin.system.bean;


import cn.hutool.core.util.StrUtil;
import lombok.Data;


@Data
public class TableColumns {

    private String field;

    private String type;

    private String key;

    private String comment;

    private String extra;

    private String collation;

    public String getJavaType() {
        if (type.contains("bigint")) {
            return "Long";
        } else if (type.contains("int")) {
            return "Integer";
        } else if (type.contains("varchar")) {
            return "String";
        } else if (type.equalsIgnoreCase("datetime")) {
            return "LocalDateTime";
        } else if (type.equalsIgnoreCase("date")) {
            return "LocalDate";
        } else if (type.contains("decimal")) {
            return "BigDecimal";
        } else if (type.contains("double")) {
            return "BigDecimal";
        } else if (type.equalsIgnoreCase("timestamp")) {
            return "Long";
        }
        return "String";
    }

    public String getJsType() {
        if (type.contains("bigint")) {
            return "number";
        } else if (type.contains("int")) {
            return "number";
        } else if (type.contains("varchar")) {
            return "string";
        } else if (type.equalsIgnoreCase("datetime")) {
            return "string";
        } else if (type.equalsIgnoreCase("date")) {
            return "string";
        } else if (type.contains("decimal")) {
            return "number";
        } else if (type.contains("double")) {
            return "number";
        } else if (type.equalsIgnoreCase("timestamp")) {
            return "number";
        }
        return "string";
    }

    public String getJavaName(){
        return StrUtil.toCamelCase(this.field);
    }

}